package com.sse.task;

import com.sse.context.SseSessionHolder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @title: HeartBeatPushServer
 * @Author xu-xiang
 * @Date: 2024/1/26 15:50
 * @description: 心跳port推送
 */
//@Service
public class HeartBeatPushServer implements ScheduledPushServer {

    private static final Logger logger = LoggerFactory.getLogger(HeartBeatPushServer.class);

    @Resource
    private Environment environment;

    @Override
    public Integer getScheduledTime() {
        return 3;
    }

    @Override
    public TimeUnit getTimeUnit() {
        return TimeUnit.SECONDS;
    }

    @Override
    public void run() {
        SseSessionHolder.sendAll("你当前正在连接的服务端口是: " + environment.getProperty("server.port", "8080"));
    }
}
